//
//  MusicListTableCell.m
//  aMoment
//
//  Created by dllo on 15/10/26.
//  Copyright © 2015年 LuckyHan. All rights reserved.
//

#import "MusicListTableCell.h"
#import "AllHeaderFiles.h"

@implementation MusicListTableCell

- (void)dealloc
{
    [_songNameLabel release];
    [_singerLabel release];
    [_downloadImageView release];
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.songNameLabel = [[UILabel alloc] init];
        _songNameLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:FONTSIZE_MIDDLE];
        _songNameLabel.textColor = [UIColor whiteColor];
        [self.contentView addSubview:_songNameLabel];
        [_songNameLabel release];
        
        self.singerLabel = [[UILabel alloc] init];
        _singerLabel.font = [UIFont systemFontOfSize:FONTSIZE_SMALL];
        _singerLabel.textColor = [UIColor whiteColor];
        [self.contentView addSubview:_singerLabel];
        [_singerLabel release];
        
        self.downloadImageView = [[UIImageView alloc] init];
        _downloadImageView.image = [UIImage imageNamed:@"iconfont-radiodownload"];
//        _downloadImageView.userInteractionEnabled = YES;
//        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(downloadAction)];
//        [_downloadImageView addGestureRecognizer:tap];
//        [tap release];
        [self.contentView addSubview:_downloadImageView];
        [_downloadImageView release];
        [_downloadImageView removeFromSuperview];
    }
    return self;
}

- (void)setMusicInfoArray:(NSArray *)musicInfoArray
{
    if (_musicInfoArray != musicInfoArray) {
        [_musicInfoArray release];
        _musicInfoArray = [musicInfoArray retain];
    }
}

//#pragma mark 下载方法
//- (void)downloadAction
//{
//    NSLog(@"tap");
//    [NetworkRequest downloadFileWithURLString:_musicInfoArray[0] WithFileName:_musicInfoArray[1] Progress:^(float progress) {
//        _block(progress);
//    } Success:^(AFHTTPRequestOperation *operation, id responseObject) {
//        
//    } Failure:^(AFHTTPRequestOperation *operation, NSError *erro) {
//        
//    }];
//}

- (void)layoutSubviews
{
    [super layoutSubviews];
    _downloadImageView.frame = CGRectMake(SCREEN_WIDTH - 20 - 32, self.contentView.center.y - IMAGE_32 / 2, IMAGE_32, IMAGE_32);
    _songNameLabel.frame = CGRectMake(20, 5, _downloadImageView.X - 20 - 10, 20);
    _singerLabel.frame = CGRectMake(_songNameLabel.X, _songNameLabel.Y + _songNameLabel.Height + 5, _songNameLabel.Width, _songNameLabel.Height);
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
